package com.zbkj.admin.controller.platform.assistant;

import com.zbkj.admin.controller.platform.assistant.service.AssistantConversationService;
import com.zbkj.common.page.CommonPage;
import com.zbkj.common.request.PageParamRequest;
import com.zbkj.common.result.CommonResult;
import com.zbkj.service.assistant.model.request.AssistantConversationCompleteRequest;
import com.zbkj.service.assistant.model.request.AssistantConversationHistorySearchRequest;
import com.zbkj.service.assistant.model.request.AssistantConversationSearchRequest;
import com.zbkj.service.assistant.model.vo.AssistantConversationVO;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 客服会话表 前端控制器
 */
@Slf4j
@RestController
@RequestMapping("api/admin/platform/assistant/conversation")
@Api(tags = "客服-会话")
public class AssistantConversationController {

    @Autowired
    private AssistantConversationService assistantConversationService;

    @ApiOperation(value = "当前客服接待的会话列表")
    @GetMapping("/list")
    public CommonResult<List<AssistantConversationVO>>  getAdminConversationList(@Validated AssistantConversationSearchRequest request) {
        List<AssistantConversationVO> list = assistantConversationService.getAdminConversationList(request);
        return CommonResult.success(list);
    }

    @ApiOperation(value = "历史会话列表")
    @GetMapping("/history/list")
    public CommonResult<CommonPage<AssistantConversationVO>>  getAdminConversationList(@Validated AssistantConversationHistorySearchRequest request, @Validated PageParamRequest pageParamRequest) {
        CommonPage<AssistantConversationVO> page = CommonPage.restPage(assistantConversationService.getAdminConversationHistoryPage(request, pageParamRequest));
        return CommonResult.success(page);
    }

    // 完成会话
    @ApiOperation(value = "完成会话")
    @PostMapping("/complete")
    public CommonResult<String> complete(@RequestBody AssistantConversationCompleteRequest request) {
        assistantConversationService.complete(request);
        return CommonResult.success();
    }

}



